package com.engine.core.util;

import com.engine.core.interceptor.ResponseCommand;
import com.engine.update.cmd.*;

public enum UpdateActionEnum {
    SAVEONE("saveOne", SaveOneCommand.class,new String[]{}),
    SAVEMULTI("save", SaveMultiCommand.class),
    UPDATEONE("updateOne", UpdateOneCommand.class),
    UPDATMULTI("update",UpdateMultiCommand .class),
    DELETEONE("deleteOne", DeleteOneCommand.class),
    DELETEMULTI("delete",DeleteMultiCommand.class),
    SAVEMAINDETAIL("saveMainDetail",SaveMainAndDetailCommand.class),
    SAVEORUPDATE("saveOrUpdate", SaveOrUpdateCommad.class);




    private String action;
    private Class<? extends ResponseCommand> command;

    private String[] checkParams;


    UpdateActionEnum(String action, Class<? extends ResponseCommand> command){
        this.action=action;
        this.command=command;
    }

    UpdateActionEnum(String action, Class<? extends ResponseCommand> command, String[] checkParams){
        this.action=action;
        this.command=command;
        this.checkParams=checkParams;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public Class<? extends ResponseCommand> getCommand() {
        return command;
    }

    public void setCommand(Class<? extends ResponseCommand> command) {
        this.command = command;
    }

    public static UpdateActionEnum get(String action){
        UpdateActionEnum r=null;
        for (UpdateActionEnum e:values()) {
            if(e.getAction().equalsIgnoreCase(action)){
                r=e;
            }
        }
        return r;
    }


}
